package com.xuecheng.order.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

//@Component
public class TaskDemo01 {
    //    记录日志
    private final static Logger LOGGER = LoggerFactory.getLogger(TaskDemo01.class);

    //    @Scheduled(cron = "0/3 * * * * *")//每隔三秒执行
    @Scheduled(fixedRate = 3000)
    public void test01() {
        LOGGER.info("====================");
        System.out.println("程序1：" + new Date());

        try {
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        LOGGER.info("====================");
    }

    @Scheduled(fixedRate = 5000)
    public void task02() {
        LOGGER.info("&&&&&&&&&&&&&&&&&&&&&");
        System.out.println("程序2：" + new Date());
    }
}
